package com.exam.Service;
import com.exam.Entity.MultipleQuestion;
import com.exam.Mapper.MultipleQuestionMapper;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MultipleQuestionService {
    @Autowired
    private MultipleQuestionMapper multipleQuestionMapper;
    public List<MultipleQuestion> findByIdAndType(Integer PaperId) {
        return multipleQuestionMapper.findByIdAndType(PaperId);
    }

    public List<MultipleQuestion> findAll(int page, int size) {
        //设置分页参数
        PageHelper.startPage(page, size);
        //执行查询
        List<MultipleQuestion> result = multipleQuestionMapper.findAll();
        // 包装分页结果
        PageInfo<MultipleQuestion> pageInfo = new PageInfo<>(result);

        return pageInfo.getList();
    }

    public MultipleQuestion findOnlyQuestionId() {
        return multipleQuestionMapper.findOnlyQuestionId();
    }
    public int add(MultipleQuestion multipleQuestion) {
        return multipleQuestionMapper.add(multipleQuestion);
    }
    public int deleteById(Integer id) {
        return multipleQuestionMapper.deleteById(id);
    }
    public List<Integer> findBySubject(String subject, Integer pageNo) {
        return multipleQuestionMapper.findBySubject(subject,pageNo);
    }
}
